/* lsw.t   ADDRESS LIST DETAIL WRITE TRIGGER                          */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :lsw.t                                                   */
/*  Author  :Gary Morales                                            */
/*  Date    :06/27/96                                                */
/*  !Description : ls_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  06/27/96 BY: GWM      *J0WB* */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy      *J12B* */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm      *J1DM* */
/*Revision 9.1          Last Modified:  08/13/00 BY: *N0KR* myb       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

trigger procedure for write of ls_mstr old buffer old_ls_mstr.

     /* THIS TRIGGER PROCEDURE SHOULD MAKE A QUICK CHECK FOR ANY */
     /* ROUTINES THAT NEED TO BE EXECUTED AS A RESULT OF THIS    */
     /* TRIGGER FIRING. IF NO ROUTINES NEED TO BE CALLED THEN    */
     /* RETURN WITHOUT DOING ANYTHING.                           */


     /* GLOBAL VARIABLES */
     {mfdeclre.i}

     /* LOCAL VARIABLES */
     define variable warehousing_active as logical no-undo.

     /* SHARED WORK TABLES */
/*J12B*/ define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.
     define new shared work-table wf_old_ls_mstr like ls_mstr.


     /* WAREHOUSING INTERFACE PROCESSING */

     WI:
     do:

/*J12B*/     warehousing_active = true.

     /* CHECK IF WAREHOUSE INTERFACE IS ACTIVE */
/*J12B       if can-find(first whl_mstr where whl_act = true no-lock) then */
/*J12B*/     if not can-find(first whl_mstr no-lock
/*J12B*/         where whl_mstr.whl_act and (whl_mstr.whl_cust_exp
/*J12B*/                                 or  whl_mstr.whl_sup_exp))
/*J12B*/     then
/*J12B           warehousing_active = true. */
         /*J12B else */ warehousing_active = false.

     /* CHECK IF PERTINENT FIELDS HAVE BEEN CHANGED */
/*J12B*/     if   (old_ls_mstr.ls_addr  = ls_mstr.ls_addr
/*J12B*/       and old_ls_mstr.ls_type  = ls_mstr.ls_type
/*J12B*/       and old_ls_mstr.ls_user1 = ls_mstr.ls_user1
/*J12B*/       and old_ls_mstr.ls_user2 = ls_mstr.ls_user2)
/*J12B*/     then warehousing_active = false.

         if warehousing_active then do:

     /* COPY THE OLD RECORD BUFFER INTO THE WORKFILE FOR  */
     /* LATER COMPARISONS TO THE NEW RECORD BUFFER        */

             create wf_old_ls_mstr.

             assign
                 wf_old_ls_mstr.ls_addr      = old_ls_mstr.ls_addr
                 wf_old_ls_mstr.ls_type      = old_ls_mstr.ls_type
                 wf_old_ls_mstr.ls_user1     = old_ls_mstr.ls_user1
                 wf_old_ls_mstr.ls_user2     = old_ls_mstr.ls_user2
             .

     /* WAREHOUSE INTERFACE LS_MSTR WRITE ROUTINE */
/*J1DM*/ /*    {gprun.i ""wilsw.p"" "(recid(ls_mstr))"} */
/*J1DM*/       {gprunmo.i &module="WI"
                          &program="wilsw.p"
                          &param="(recid(ls_mstr))"}


         end. /* IF WAREHOUSE INTERFACE ACTIVE */

/*J12B*/ end. /* WI */
